package main
import (
	"fmt"
	_"math/rand"
	"time"
	"math"
)

func main(){
	//1、循环打印输入月份的天数【使用continue】

	/*var year,month int
	for{
		fmt.Printf("请输入年份：")
		fmt.Scanln(&year)
		if year < 1990{
			fmt.Println("输入有误！")
			continue
		}
		fmt.Printf("请输入月份：")
		fmt.Scanln(&month)
		if month > 12 || month < 1{
			fmt.Println("输入有误！")
			continue			
		}
		fmt.Println("该月份有 ：",exec1(year,month)," 天 ")
	}*/
	
	//2、随机猜数游戏，随机生成1-100的整数，有十次机会

	/*rand.Seed(time.Now().UnixNano())
	num := rand.Intn(100)+1
	fmt.Println("test answer : ",num)
	exec2(num)*/

	//3、输出100以内所有素数，每行五个，并求和

	/*sum := 0
	count := 0
	for i := 1;i <= 100;i++{
		if exec3(i) {
			fmt.Printf("%d\t",i)
			sum += i
			count++
		}
		if count == 5 {
			fmt.Printf("%d \n",sum)
			count = 0
			sum = 0
		}
	}*/
	

	//4、三天打鱼两天晒网，问某一天是打鱼还是晒网！从1990/01/01开始

	/*var y,d int
	var m time.Month
	fmt.Printf("请输入年份：")
	fmt.Scanln(&y)
	fmt.Printf("请输入月份(01-12)：")
	fmt.Scanln(&m)
	fmt.Printf("请输入具体某一天：")
	fmt.Scanln(&d)
	exec4(y,d,m)*/

	//5、小小计算器
	
	/*略*/

	//6、输出小写a-z以及大写Z-A
	exec6()
	
}
func exec1(y,m int) int{
	switch m {
	case 1,3,5,7,8,10,12:
		return 31
	case 2:
		if y % 400 == 0 || (y % 4 == 0 && y % 100 != 0){
			return 29
		}
		return 28
	default:
		return 30
	}
}
func exec2(randnum int){
	var youranswer,i int
	for i = 1;i <= 10;i++{
		fmt.Println("your number is :")
		fmt.Scanln(&youranswer)
		if youranswer == randnum{
			break
		}
	}
	switch i {
	case 1:
		fmt.Println("噢，居然一次就对了！真棒")
	case 2,3,4:
		fmt.Println("可以，很棒!")
	case 5,6,7:
		fmt.Println("哎呀，快被你超越了！")
	case 8,9,10:
		fmt.Println("差点就输了呢~~~")
	default:
		fmt.Println("有点小失望~一次都没对")
	}
}
func exec3(n int)bool{
	for i := 2;i <= int(math.Sqrt(float64(n)));i++{
		if n % i == 0{
			return false
		}
	}
	return true
}
func exec4(y,d int,m time.Month){
	loc, _ := time.LoadLocation("Local")
	t := time.Date(y,m,d,0,0,0,0,loc)
	fmt.Println("time is : ",t.Format("2006/01/02 15:04:05"))	
	second := t.Unix()
	day := second / 86400
	temp := day % 5 
	if temp >= 1 && temp < 4{
		fmt.Printf("打鱼ing")
	}else{
		fmt.Printf("晒网ing")
	}
}
func exec6(){
	var c byte = 96 //Z : 90
	for i := 0;i<=25;i++{
		c = c+byte(1)
		fmt.Printf("%c ",c)
		defer fmt.Printf("%c ",c-byte(32))
	}
}